package br.com.polo.contas.web.manageBeans;

import java.util.Calendar;

import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.persistence.PersistenceException;
import javax.validation.ConstraintViolationException;

import br.com.polo.contas.dominio.Conta;
import br.com.polo.contas.persistencia.dao.repositorio.ContaRepository;

@ManagedBean
@RequestScoped
public class ContaController {
	
	@EJB
	ContaRepository contaRepository;

	private Conta conta;
	
	public ContaController() {
		conta = new Conta();
	}
	
	public void cadastrarConta(){
		
		//Define a data de lancamento
		conta.setDtLancamento(Calendar.getInstance());
		
		contaRepository.cadastrarConta(conta);
	
	}

	/**
	 * @return Conta conta
	 */
	public Conta getConta() {
		return conta;
	}

	/**
	 * @param Conta conta
	 */
	public void setConta(Conta conta) {
		this.conta = conta;
	}	
	
}
